export default {
	tabto(url){this.navto(url)},
	switchto(url){this.navto(url)},
    navto (url) {
		// this.log(e)
		// let data = {}
		// let url = e.currentTarget.dataset.url
  //       if(e !== undefined){
  //       	data = e.currentTarget.dataset
  //       }
        let p = "?"
   //      for (var i in data){
			// if( i === 'eventOpts')continue;
			// if( i === 'eventParams')continue;
			// if( i === 'url')continue;
			// p = p + (p === "?"?'':'&') + i + '=' + data[i]
   //      }
        // this.log(e)
        uni.switchTab({
            url: url + p
        });
    },
    goto (url,e) {
		// this.log(e)
		let data = {}
		if(e !== undefined){
			data = e.currentTarget.dataset
		}
		// this.log(data)
		let p = ""
		for (var i in data){
		// this.log(i)
			if( i === 'eventOpts')continue;
			if( i === 'eventParams')continue;
			p = p + (p === ""?'?':'&') + i + '=' + data[i]
		}
		// console.log(url + p)
		setTimeout(()=>{
			uni.navigateTo({
				url: url + p,
				// animationType:"slide-in-right",
				animationType:"fade-in",
				animationDuration:400
			});
		},50)
    },
    gointo (url,data) {
        
        setTimeout(()=>{
        	uni.redirectTo({
        	    url: url,
        		// animationType:"slide-in-right",
        		animationType:"fade-in",
        		animationDuration:400
        	});
        },50)
    },
    goback (delta) {
		if(delta == undefined)delta = 1
        uni.navigateBack({
            delta: delta
        });
    },
    gohome () {
		uni.switchTab({
		    url: '/pages/machine/index'
		});
    }
}
